<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <input v-model="number1"/>
      <select v-model="selectedMark">
          <option v-for="mark in marks" :value="mark.mark">{{mark.mark}}</option>
      </select>
    <input v-model="number2"/>
    <button @click="markHandle">=</button><span>{{result}}</span>
</div>
</body>
<!--
     var num = '10';
     num =  parseInt(num);//把文本转成数字
-->
<script src="../../lib/vue.js"></script>
<script>

    new Vue({
        el:'#app',
        data:{
            number1:0,
            number2:0,
            selectedMark:'+',
            marks:[
                {
                    id:1,
                    mark:'+'
                }, {
                    id:2,
                    mark:'-'
                }, {
                    id:3,
                    mark:'*'
                }, {
                    id:4,
                    mark:'/'
                }
            ]
        },methods:{
            markHandle:function () {
               /* if(this.selectedMark=='+'){
                    this.result = parseInt(this.number1) + parseInt(this.number2)  ;
                }

                if(this.selectedMark=='-'){
                    this.result = parseInt(this.number1) - parseInt(this.number2)  ;
                }*/

                this.result = eval(this.number1+this.selectedMark+this.number2); // eval(str)

            }
        },computed:{
            result:function () {
                return eval(this.number1+this.selectedMark+this.number2); // eval(str)

            }
        }
    })
</script>
</html>